package com.neutech.solar.client;

import com.neutech.solar.entity.AbstractFrame;
import com.neutech.solar.entity.Background;
import com.neutech.solar.entity.Planet;
import com.neutech.solar.entity.Sun;
import java.util.List;
import java.awt.*;
import java.util.ArrayList;
import java.util.Random;

public class SolarSystemClient extends AbstractFrame {
   public Background bg = new Background();
   public Sun sun = new Sun();
    Planet Venus = new Planet(sun,"Venus",0.72,0.0068,225,"金星",false,true);
    Planet Earth = new Planet(sun,"Earth",1,0.0167,365,"地球");
    //Planet moon = new Planet(Earth,"smallPlanet",0.3,0.0,365/12,"");



    Planet Huo = new Planet(sun,"Huo",1.52,0.0934,687,"火星");
    Planet Shui = new Planet(sun,"Shui",0.387,0.2056,88,"水星");
    Planet Mu = new Planet(sun,"Mu",5.2,0.0489,4330,"木星");
    Planet Tu = new Planet(sun,"Tu",9.54,0.0557,10832,"土星");
    Planet Hai = new Planet(sun,"Hai",30.06,0.0112,60328,"海王星");
    Planet Tian = new Planet(sun,"Tian",19.218,0.0444,30777,"天王星");
    Planet Hui = new Planet(sun,"Venus",17.8,0.967,27485,"哈雷彗星");
    List<Planet> planets = new ArrayList<>();
    Random r =new Random();

    {
        for (int i = 0; i < 1000; i++) {
            double AU = r.nextDouble() * 2 + 2.0;
            int T = r.nextInt(3300) + 700;
            Planet smallPlanet = new Planet(sun,"smallPlanet",AU,0.0,T,"",true);
            planets.add(smallPlanet);
        }
    }
    public SolarSystemClient(){
        super.init("太阳系八行星运行系统");
    }

    @Override
    public void paint(Graphics g) {
        bg.draw(g);
        sun.draw(g);
        Earth.draw(g);
        Shui.draw(g);
        Venus.draw(g);
        Huo.draw(g);
       //小行星带
        for (Planet smallPlanet : planets ){
            smallPlanet.draw(g);
        }
        Mu.draw(g);
        Tu.draw(g);
        Hai.draw(g);
        Tian.draw(g);
        Hui.draw(g);
        //moon.draw(g);
    }

    public static void main(String[] args) {
        new SolarSystemClient();
    }
}
